package other.sort;

import common.util.MyUtil;

/**
 * @author guichang
 * @date 2020/9/23
 */

public class P2_插入排序 {

    public static void main(String[] args) {
        int[] nums = MyUtil.createRandomArray(20, 1, 99);

        for (int i = 1; i < nums.length; i++) {
            for (int j = i - 1; j >= 0 && nums[j] > nums[j + 1]; j--) {
                MyUtil.swap(nums, j, j + 1);
            }
        }

        MyUtil.printInt(nums);
    }

}